package com.boatAnchorAssistant.service.repository.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.boatAnchorAssistant.pojo.entity.AlarmType;
import com.boatAnchorAssistant.pojo.entity.EventGroup;
import com.boatAnchorAssistant.service.mapper.AlarmTypeMapper;
import com.boatAnchorAssistant.service.repository.in.AlarmTypeRepository;
import nirvana.core.repository.Repository;
import org.springframework.stereotype.Service;
    import com.boatAnchorAssistant.pojo.dto.alarmType.*;
    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@Service
public class AlarmTypeRepositoryImpl extends Repository< AlarmTypeMapper , AlarmType> implements AlarmTypeRepository {

private final AlarmTypeMapper mapper;

public AlarmTypeRepositoryImpl(AlarmTypeMapper mapper) {
this.mapper = mapper;
}

    /**
    * 搜索报警类型
    * @param dto
    * @return
    */
    @Override
    public Page< AlarmType > selectAlarmType(SelectAlarmTypeDto dto){

    return mapper.selectAlarmType(dto);
    }

    @Override
    public Map<Long, AlarmType> getMap(List<Long> ids) {
        Map<Long, AlarmType> map = new HashMap<>();

        if (CollectionUtil.isNotEmpty(ids)) {
            List<AlarmType> list =listByIds(ids);
            if (CollectionUtil.isNotEmpty(list)) {
                map = list.stream().collect(Collectors.toMap(AlarmType::getId, pojo -> pojo));
            }
        }
        return map;
    }


}